package com.lysj.bhp.financial.repository;

import com.lysj.bhp.financial.domain.UserEarningsRecord;
import com.lysj.bhp.financial.vo.UserEarningsRecordVo;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface UserEarningsRecordRepository extends JpaRepository<UserEarningsRecord, Long>, JpaSpecificationExecutor {


    List<UserEarningsRecord> findByUserFinancialRecordId(Long userFinancialRecordId);

    @Query("SELECT NEW com.lysj.bhp.financial.vo.UserEarningsRecordVo(a.divided,a.createDate,b.earningsType) from UserEarningsRecord  a,Financial b where a.financialId = b.financialId  AND a.financialId = ?1 ORDER BY a.createDate desc ")
    Page<UserEarningsRecordVo> findUserEarningsRecord(Pageable page, Long financialId);

}
